<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:composition template="/template.xhtml">
        <ui:define name="breadcrumbs">
        <h:form>
            <a href="index.xhtml">Website Admin</a><div class="breadcrumb_divider"></div>
            <h:commandLink action="#{examsController.prepareList()}" value="Exams" class="current"/>
        </h:form>
        </ui:define>
        <ui:define name="body">
            <h:form styleClass="jsfcrud_list_form" id="form">
                <h:panelGroup id="messagePanel" layout="block">
                    <h:messages errorClass="errorStyle" infoClass="infoStyle" layout="table" >
                    </h:messages>
                </h:panelGroup>

                <h:outputText escape="false" value="#{bundle.ListCoursesEmpty}" rendered="#{examsController.items.rowCount == 0}" class="infoStyle"> 
                </h:outputText>
                <article class="module width_full">
			<header><h3>Search Exam</h3></header>
                        <div class="module_content">
                            <h:panelGrid columns="5" width="100%">
                                <h:outputText value="Create Date:" />
                                <h:outputText value="From date:" />
                                <p:calendar value="#{examsController.searchFromdate}" pattern="MM/dd/yyyy HH:mm"></p:calendar>
                                <h:outputText value="To date:" />
                                <p:calendar value="#{examsController.searchTodate}" pattern="MM/dd/yyyy HH:mm"></p:calendar>
                                <h:outputText value="Assign Faculty:" />
                                <p:selectOneMenu id="searchAss" value="#{examsController.searchFac}" effect="fold">
                                    <f:selectItem itemLabel="---Select----" />
                                    <f:selectItems value="#{examsController.allFac}" var="userSearch" itemLabel="#{userSearch}" itemValue="#{userSearch}"/>
                                </p:selectOneMenu>
                                <h:outputText value="Subject:" />
                                <p:selectOneMenu id="subjectId" value="#{examsController.searchSub}" effect="fold">
                                    <f:selectItem itemLabel="---Select----" />
                                    <f:selectItems value="#{examsController.allSubject}"/>
                                    <p:ajax update="searchAss" event="change"/>
                                </p:selectOneMenu>
                                <h:commandButton value="Search" action="#{examsController.searchExams}"/>
                            </h:panelGrid>
                        </div>
                </article>
                <article class="module width_full">
			<header><h3>List of Exams</h3></header>
                        <div class="module_content">
                <h:panelGroup rendered="#{examsController.items.rowCount > 0}">
                    <p:dataTable value="#{examsController.items}" var="item" paginator="true" rows="10" 
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                     rowsPerPageTemplate="5,10,15" style="width: 100%" styleClass="tablesorter" >
                        <p:column sortBy="#{item.id}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListExamsTitle_id}"/>
                            </f:facet>
                            <h:outputText value="#{item.id}"/>
                        </p:column>
                        <p:column sortBy="#{item.examId}">
                            <f:facet name="header">
                                <h:outputText value="Exam code"/>
                            </f:facet>
                            <h:outputText value="#{item.examId}">
                            </h:outputText>
                        </p:column>
                        <p:column sortBy="#{item.assignFac.lastName}">
                            <f:facet name="header">
                                <h:outputText value="Assign faculty"/>
                            </f:facet>
                            <h:outputText value="#{item.assignFac.firstName}"/> 
                            <h:outputText value="&nbsp;"/>
                            <h:outputText value="#{item.assignFac.lastName}"/> 
                        </p:column>
                        <p:column sortBy="#{item.dateStart}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListExamsTitle_dateStart}"/>
                            </f:facet>
                            <h:outputText value="#{item.dateStart}">
                                <f:convertDateTime pattern="MM/dd/yyyy HH:mm:ss" />
                            </h:outputText>
                        </p:column>
                        <p:column sortBy="#{item.dateEnd}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListExamsTitle_dateEnd}"/>
                            </f:facet>
                            <h:outputText value="#{item.dateEnd}">
                                <f:convertDateTime pattern="MM/dd/yyyy HH:mm:ss" />
                            </h:outputText>
                        </p:column>
                        <p:column sortBy="#{item.dateReCounting}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListExamsTitle_dateReCounting}"/>
                            </f:facet>
                            <h:outputText value="#{item.dateReCounting}">
                                <f:convertDateTime pattern="MM/dd/yyyy HH:mm:ss" />
                            </h:outputText>
                        </p:column>
                        <p:column sortBy="#{item.subjectId.suName}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListExamsTitle_subjectId}"/>
                            </f:facet>
                            <h:outputText value="#{item.subjectId.suName}"/>
                        </p:column>
                        <p:column style="width: 130px; text-align: center;">
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:commandButton action="#{examsController.prepareEdit()}" title="Edit"
                                            image="#{resource['images:icn_edit_article.png']}">
                               <f:setPropertyActionListener value="#{item}" target="#{examsController.selected}"/>
                           </h:commandButton>
                           <h:outputText value="&nbsp;"/>
                           <h:commandButton action="#{examsController.destroy}" title="Delete"
                                            image="#{resource['images:icn_trash.png']}">
                               <f:setPropertyActionListener value="#{item}" target="#{examsController.selected}"/>

                           </h:commandButton>
                           <h:outputText value="&nbsp;"/>
                           <h:commandButton action="#{examsController.prepareView()}" title="View"
                                            image="#{resource['images:icn_folder.png']}">
                               <f:setPropertyActionListener value="#{item}" target="#{examsController.selected}"/>
                           </h:commandButton>
                        </p:column>
                    </p:dataTable>
                </h:panelGroup>
                <br />
                <h:commandButton action="#{examsController.prepareCreate}" value="#{bundle.ListExamsCreateLink}"/>
                <br />
                <br />
                
                        </div>
                </article>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
